﻿using FluentValidation;
using PMS.Data.Entities.Settings;
using PMS.Web.Framework.Validators;
using PMS.Web.Models.Customers;

namespace PMS.Web.Validators.Customer
{
    public partial class PasswordRecoveryValidator : BaseModelValidator<PasswordRecoveryModel>
    {
        public PasswordRecoveryValidator(CustomerSettings customerSettings)
        {

            RuleFor(x => x.Mobile).IsMobileNumber(customerSettings)
                .When(x => !x.RecoverByEmail)
                .WithMessage(ValidatorRuleString.Validators_MobilePhone);
            RuleFor(x => x.Email).NotEmpty()
                .When(x => x.RecoverByEmail)
                .WithMessage(ValidatorRuleString.EmailRequired);
            RuleFor(x => x.Email).EmailAddress()
                .When(x => x.RecoverByEmail)
                .WithMessage(ValidatorRuleString.Validators_Email);
        }
    }
}
